CC = mipsel-openwrt-linux-gcc
#CC = gcc
COMPILE_FLAG = -O0 -Wall 
LIBS = -lpthread -ldl -lm -lghttp -liniparser
SRC_DIRECTORY := src
BUILD_DIRECTORY := bin
INCLUDES := -I ../inc -L ../lib


all: test_log test_uart test_get_wifi_ap test_ipc_msg_send test_ipc_msg_recv test_config


test_log:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/test_log test_log.c ../src/log.c $(LIBS)


test_uart:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/test_uart test_uart.c ../src/uart.c $(LIBS)

test_get_wifi_ap:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/test_get_wifi_ap test_get_wifi_ap.c ../src/get_wifi_ap.c $(LIBS)


test_ipc_msg_send:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/test_ipc_msg_send test_ipc_msg_send.c ../src/uart.c  ../src/ipc_msg.c $(LIBS)


test_ipc_msg_recv:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/test_ipc_msg_recv test_ipc_msg_recv.c ../src/ipc_msg.c ../src/wifi_data.c ../src/get_wifi_ap.c ../src/cJSON.c ../src/conf.c $(LIBS)

test_config:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/test_config test_config.c ../src/conf.c $(LIBS)


clean:
	rm -rf bin